<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app"></div>
    <hr>

    <div id="hello"></div>

    <template id="content">
        <h2 @click="print">模板内容：{{ msg }}</h2>
    </template>
</body>
<script>
    // 创建子类构造器，也称为组件构造器 
    var MyVue = Vue.extend({
        template:'#content',
        data:function(){
            return {
                msg:'welcome'
            }
        },
        methods: {
            print(){
                console.log('print...')
            }
        },
    })

    // 使用子类构造器创建Vue实例（组件）
    var vm1 = new MyVue({
        data:{
            name:'tom',
            msg:'欢迎'
        }
    })
    vm1.$mount('#app')

    var vm2 = new MyVue()
    vm2.$mount('#hello')


</script>
</html>